package com.tbit.uqbike.client.controller;

import com.tbit.uqbike.client.pojo.InvoiceTitle;
import com.tbit.uqbike.client.pojo.Result;
import com.tbit.uqbike.client.pojo.dto.AddInvoiceTitleDTO;
import com.tbit.uqbike.client.pojo.dto.UpdateInvoiceTitleDTO;
import com.tbit.uqbike.client.service.InvoiceTitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 发票抬头信息
 *
 * @Author:BUGTian
 * @DATE: 2023/9/4
 */
@RestController("/invoiceTitle")
public class InvoiceTitleController {
    @Autowired
    private InvoiceTitleService invoiceTitleService;


    /**
     * 获取用户发票抬头信息
     *
     * @param token
     * @return
     */
    @GetMapping("/get")
    public Result<List<InvoiceTitle>> getInvoiceTitle(@NotNull String token) {
        return invoiceTitleService.getInvoiceTitle(token);
    }

    /**
     * 添加用户发票抬头
     *
     * @param addInvoiceTitleDTO
     * @return
     */
    @PostMapping("/add")
    public Result addInvoiceTitle(@NotNull String token, @RequestBody AddInvoiceTitleDTO addInvoiceTitleDTO) {
        return invoiceTitleService.addInvoiceTitle(addInvoiceTitleDTO, token);
    }

    /**
     * 修改用户发票抬头
     *
     * @param updateInvoiceTitleDTO
     * @return
     */
    @PutMapping("/update")
    public Result updateInvoiceTitle(@NotNull String token, @RequestBody UpdateInvoiceTitleDTO updateInvoiceTitleDTO) {
        return invoiceTitleService.updateInvoiceTitle(updateInvoiceTitleDTO, token);
    }

    /**
     * 删除用户发票抬头
     *
     * @param token
     * @param invoiceTitleId
     * @return
     */
    @DeleteMapping("/delete")
    public Result deleteInvoiceTitle(@NotNull String token, @NotNull Integer invoiceTitleId) {
        return invoiceTitleService.deleteInvoiceTitle(token, invoiceTitleId);
    }
}
